package project.dao.impl;


import project.bean.UserBean;
import project.dao.IUserDao;

import java.sql.SQLException;

public class UserDaoImpl extends BaseDao implements IUserDao {

    @Override
    public UserBean login(String name, String pwd) {
        UserBean userBean = null;
        this.setConnection();
        try {
            ps=con.prepareStatement("SELECT * FROM  t_user WHERE t_name= ?AND t_pwd=?;");
            ps.setObject(1,name);
            ps.setObject(2,pwd);
            rs= ps.executeQuery();
            while (rs.next()){
                userBean=new UserBean();
                userBean.setUserName(rs.getString("t_name"));
                userBean.setPassWord(rs.getString("t_pwd"));
            }

        } catch (SQLException e) {
            throw new RuntimeException(e);
        }finally {
            this.closeConnection();
        }
        return userBean ;
    }
}
